let app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        select:0,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        let d = app.globalData;
        this.setData({
            platform:d.platform,    
            //userInfo:userInfo,
            width:d.windowWidth,
            height:d.windowHeight,
            statusBarHeight:d.statusBarHeight,
            navHeight:d.navHeight,
            navWidth:d.navWidth,
            navRight:d.navRight,
            marginTop:d.navTitleTop,
            domain:d.domain,
            uploadUrl:d.uploadUrl,
          })
    },
    goBack(){
        wx.navigateBack();
    },
    goIndex(){
        var  url ='/pages/customer/index';
        console.log(url);
        wx.reLaunch({
          url:url
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        this.getIndex();
    },
    getIndex(){
        let that = this;
        var userInfo =  wx.getStorageSync('userInfo');
        var data = [];
        data['user_id']= userInfo.id;
       // data['now']= value;
        var url = 'customer/getLoseList';

      app.request(url,data,'get').then(res=>{ 
        console.log('---customer ----getLoseList'); 
         console.log(res);
         that.setData({
             list:res.list
         })
      });
    },
    boxChange(e){
        console.log(e);
        var selectList = e.detail.value;
        var select = selectList.length;
        this.setData({
            select:select,
            selectList:selectList
        })
        //console.log(select)
    },
    reject(){
        var d = this.data;
        let that = this;
        var userInfo =  wx.getStorageSync('userInfo');
        var data = [];
        data['user_id'] = userInfo.id;
        var lists=d.selectList;
        if(d.select == 0){
            app.showModals('请选择客户','#','#');
            return;
        }
        var list= lists.toString();
        console.log(list);
        data['list'] = list;
        console.log(data)
        var url = 'customer/loseToReject';

      app.request(url,data,'get').then(res=>{ 
        console.log('---customer ----lose to reject'); 
         console.log(res);
         app.showModals(res.msg,res.url,res.index);
         that.getIndex();
      });
    },
    putPub(){
        var d = this.data;
        let that = this;
        var userInfo =  wx.getStorageSync('userInfo');
        var data = [];
        data['user_id'] = userInfo.id;
        if(d.select == 0){
           // console.log();
           app.showModals('请选择客户','#','#');
            return;
        }
        var list= d.selectList.toString();
        console.log(list);
        data['list'] = list;
        console.log(data)
        var url = 'customer/toPub';

      app.request(url,data,'get').then(res=>{ 
        console.log('---customer ----lose to reject'); 
         console.log(res);
         app.showModals(res.msg,res.url,res.index);
         that.getIndex();
      });
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})